<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">

<style type="text/css">
#listT td {
	border: 1px solid #dddddd;
}
#bannerT td {
	border: 0px;
}
</style>

<script src="resources/js/paging/paging.js"></script>
<script type="text/javascript">
$(function() {
	setPage({
		page: $("#pageNum").val(),
		totalCount: $("#totalCount").val(),
		naviId: "naviPage",
		funcName: "getEventList",
		pageSize: pageSize
	});
});

function deleteEvent(ev_no) {
	if( confirm("정말로 삭제하시겠습니까?") != 0 ) {
		$.ajax({
			url: "deleteEvent.ga",
			type: "post",
			dataType: "html",
			data: {
				ev_no: ev_no
			},
			success: function(data) {
				if( data == 1 ) {
					alert("정상적으로 삭제되었습니다.");
					location.href = "eventList.ga";
				} else {
					alert("삭제에 실패했습니다. 다시 시도하여 주세요.");
				}
			},
			error: function() {
				alert("오류");
			}
		});
	}
}

</script>

</head>
<body>

<input type="hidden" id="pageNum" value="${pageNum }"/>
<input type="hidden" id="totalCount" value="${totalCount }"/>

<table id="listT" cellpadding="5" cellspacing="0" style="width:70%;">
	<c:if test="${fn:length(resultList) <= 0 }">
		<tr style="height:350px;">
			<td><div style="text-align:center;">리스트가 없습니다.</div></td>
		</tr>
	</c:if>
	
	<c:if test="${fn:length(resultList) > 0 }">
		<c:forEach var="list" items="${resultList }">
			<tr>
				<td class="table_titleHeight" style="width:8%;">번호</td>
				<td style="width:10%;">${list.ev_no }</td>
				<td class="table_titleHeight" style="width:8%;">제목</td>
				<td style="width:30%;">${list.ev_subject }</td>
				<td class="table_titleHeight" style="width:8%;">노출 기간</td>
				<td style="width:20%;">${list.ev_startdate } ~ ${list.ev_enddate }</td>
				<td style="width:8%;"><input type="button" value="수정" onclick="location.href='modifyEventForm.ga?ev_no=${list.ev_no}'"/></td>
				<td style="width:8%;"><input type="button" value="삭제" onclick="deleteEvent(${list.ev_no})"/></td>
			</tr>
			<tr>
				<td colspan="8" style="text-align:center;">
					<img src="resources/images/uploadFiles/${list.ev_image }" style="width:640px;height:150px;"/>
				</td>
			</tr>
		</c:forEach>
	</c:if>
</table>
<br/><br/>

<c:if test="${fn:length(resultList) > 0 }">
	<div id="naviPage" style="text-align:center;"></div>
</c:if>

</body>
</html>